﻿@using GlobalResources
@using Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Helpers
@model Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Web.Models.RegisteredDeviceModel

@{
    ViewBag.Title = @Strings.RemoveDevice;
    Layout = "~/Views/Shared/_LayoutNoNavigation.cshtml";
}

<header class="header_main">
    <button class="header_main__button_back" type="button"></button>
    <h2 class="header_main__subhead header_main__subhead--large">@String.Format(@Strings.RemoveDeviceFormatted, @Model.DeviceId)</h2>
</header>

<div class="content_outer">

    <div class="content_inner">
        <div id="content">
                @using (Ajax.BeginForm("DeleteDevice", "Device", null,
                    new AjaxOptions()
                    {
                        HttpMethod = "POST",
                        InsertionMode = InsertionMode.Replace,
                        OnFailure = "IoTApp.RemoveDevice.onFailure",
                        OnSuccess = "IoTApp.RemoveDevice.onSuccess",
                        LoadingElementId = "loadingElement"
                    }))
                {
                    @Html.AntiForgeryToken()
                    <div id="removeDeviceContainer">

                        <fieldset class="remove_form">
                            <p class="remove_form__remove_confirmation">@Strings.RemoveDeviceConfirmationPart1</p>
                            <p class="remove_form__remove_confirmation">@Strings.RemoveDeviceConfirmationPart2</p>
                            <div class="remove_checkbox">
                                <input type="checkbox" class="remove_checkbox_check" id="removeDeviceCheckbox" />
                                <label class="remove_checkbox__label" for="removeDeviceCheckbox">@String.Format(@Strings.YesRemoveDeviceFormatted, @Model.DeviceId)</label>
                            </div>
                        </fieldset>

                        <fieldset class="fieldset_button">
                            @Html.HiddenFor(m => m.DeviceId)
                            <button id="removeDevice" disabled="disabled" class="button_base">@Strings.RemoveDeviceConfirmation</button>
                            <button id="cancelButton" type="button" class="button_base button_secondary">@Strings.Cancel</button>
                        </fieldset>
                    </div>
                }

        </div>
    </div>
</div>

<script>
    "use strict";

    var resources = {
        redirectToIndexUrl: '@Url.Action("Index", "Device")',
        errorRemoveDevice: '@Html.JavaScriptString(Strings.ErrorRemoveDevice)'
    };
</script>

<script type="text/javascript" src="~/Scripts/Views/Device/RemoveDevice.js?ver=@Constants.JSVersion"></script>